package org.ax.service.plan.imple;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.ax.mapper.plan.CustomMapper;
import org.ax.pojo.plan.Custom;
import org.ax.pojo.sys.User;
import org.ax.service.plan.CustomService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 编程人:赵浩鑫
 * 时间:2021-02-25-14:38
 */
@Service
public class ICustomService extends ServiceImpl<CustomMapper,Custom> implements CustomService {
    @Override
    public Page<Custom> findCustomList(Page page, String customName,String status) {
        QueryWrapper<Custom> wrapper=new QueryWrapper<Custom>();
        wrapper.like(!StringUtils.isBlank(customName), "custom_name", customName);
        wrapper.eq(!StringUtils.isBlank(status), "status", status);
        Page<Custom> page1 = getBaseMapper().selectPage(page, wrapper);
        return page1;
    }

    @Override
    public boolean addCustom(Custom custom) {
        return getBaseMapper().insert(custom)>0;
    }

    @Override
    public boolean updateCustom(Custom custom) {
        return getBaseMapper().updateById(custom)>0;
    }

    @Override
    public boolean deletesCustom(String[] ids) {
        return getBaseMapper().deleteBatchIds(Arrays.asList(ids))>0;
    }

    @Override
    public Custom toCustomId(String id) {
        return getBaseMapper().selectById(id);
    }

    @Override
    public List<Custom> availableCustom() {
        QueryWrapper<Custom> wrapper=new QueryWrapper<Custom>();
        wrapper.eq("status", "1");
        return getBaseMapper().selectList(wrapper);
    }


}
